<%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
<%@ page import="java.lang.reflect.*" %>
<%@page import="java.util.Date"%>
<%@page import="com.javaeye.common.util.DateUtils"%>
<%  
ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");
Object condition = vs.findValue("condition");
Class temp = condition.getClass();
Field[] fb = temp.getDeclaredFields();
%>

<script type="text/javascript" language="javascript">
function goBack() {
	var url = '<%= request.getHeader("REFERER")%>';
	$("#backableForm").attr("action",url);
	$("#backableForm").submit();
}
$(document).ready(function() {
	var backableDiv = $("#backableDiv");
	if (backableDiv && backableDiv.length > 0) {
		backableDiv.html(
		   	'<form id="backableForm" method="post">'
		    + '<s:hidden name="pageInfo.pageIndex" />'
		    <%for (int j = 0; j < fb.length; j++) {
		    	Field f = fb[j];
		    	String name = f.getName();
		    	if ("serialVersionUID".equals(name)) {
		    		continue;
		    	}
		    	Class type = f.getType();
		    	f = temp.getDeclaredField(name);  
		    	f.setAccessible(true);  
		    	Object value = f.get(condition);
		    	if (value == null || "null".equals(value.toString())) {
		    		value = "";
		    	}
				if (type.equals(Date.class) && !"".equals(value)) {
					value = DateUtils.formatString((Date)value, "yyyy-MM-dd");
		    	}
		    	if (type.isArray() && !"".equals(value)) {
		    		value = Array.get(value, 0);
		    	}
		    	out.println("+ '<input type=\"hidden\" name=\"condition." + name + "\" value=\"" + value + "\" />'");  
		    }%>
		    + '</form>');
	}
});
</script>